package com.baba.shop.controller.brand;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.baba.shop.bean.brand.Brand;
import com.baba.shop.service.BrandService;
import com.baba.shop.utils.Page;

@Controller
public class BrandController {
	@Autowired
	BrandService brandService;
	
	@RequestMapping("/brand/list.do")
	public String brandList(String name,Integer pageNum,ModelMap modelMap) {
		Brand brand = new Brand();
		if(StringUtils.isNotBlank(name))
			brand.setName(name);
		brand.setPageNum(pageNum);
		Page<Brand> page = brandService.getBrandList(brand);
		
		modelMap.addAttribute("page", page);
		return "brand/list";
	}
}
